feat: DH-21757: WidgetPlugin support in deephaven.ui#1341
Conversation
- Needs deephaven/web-client-ui#2648 - WidgetPlugin just registers directly - Allows for nested ui.resolve deephaven.ui components - Still maintain DashboardPlugin to handle legacy behaviour - Works with the ui_home_screen, nested dashboards, etc - Styling a little bit different (ui.panel is automatically wrapped in a nested dashboard rather than opening up panels in the existing dashboard like before) - Dashboard now has a `show_headers` option that can be set to False to not show headers on a dashboard. Useful if you're doing a homescreen type dashboard
- Add moduleNameMapper in jest.config.cjs to resolve React 18 from the plugin's local node_modules, fixing dual-React-instance errors - Mock usePersistentState in @deephaven/plugin mock to avoid FiberProvider dependency in tests - Update DocumentHandler test to reflect new behavior where non-layout children are rendered directly without ReactPanel wrapping
- Wrap bare (non-layout) widget children in DefaultPanelContent so they receive padding and surface widget loading/error states (fixes the ui_boom_counter error overlay not appearing after the WidgetPlugin refactor). - Add a styles.scss rule that strips the outer ReactPanel padding when its only child is a .dh-nested-dashboard, eliminating the duplicate padding around nested dashboards (e.g. ui_deeply_nested_dashboard).
- There's an issue here - when the ui.dashboard is the othermost thing, it should just take over the outer dashboard. Right now it's embeddign in. Need to fix that.
When a deephaven.ui widget is a single ui.panel hosted by the core WidgetPanel (e.g. opened via the WidgetPlugin in a code studio or in the embed widget scenario), render the panel's children inline using DefaultPanelContent instead of opening another GoldenLayout panel. Previously this produced a panel tab nested inside another panel tab. DefaultPanelContent now forwards the same View/Flex props that ReactPanel accepts so the user's ui.panel styling (padding, direction, gap, etc.) is preserved when rendered inline, and applies the dh-react-panel/dh-inner-react-panel class names so existing CSS rules (grid/chart padding strip, etc.) still apply. Also scope the nested-dashboard padding rule to .dh-react-panel so the outer WidgetPanel does not add extra padding around a top-level ui.dashboard in the embed widget scenario.
|
ui docs preview (Available for 14 days) |
- Shouldn't need to update all of these, there are likely some other fixes I need to do.
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
- now we don't have padding on the dashboard in the embed widget app scenario
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
dsmmcken
left a comment
There was a problem hiding this comment.
Are all the other e2e changes expected?
| "Value=i%2==0 ? `A` : `B`", | ||
| "Row=i", | ||
| ] | ||
| ) |
There was a problem hiding this comment.
You shouldn't use a timetable in e2e tests, you don't want anything ticking.
Though it doesn't look like the e2e tests display this, on screen. I think you should still switch it over so agents to follow it as a pattern.
Co-authored-by: Don <dsmmcken@gmail.com>
|
Adding @dgodinez-dh as the primary reviewer as he'll have more cycles this week than @vbabich |
|
ui docs preview (Available for 14 days) |
|
ui docs preview (Available for 14 days) |
|
@dsmmcken related to the other e2e changes:
we'd open them as a stack. This was inconsistent with how they were when it was displayed within a dashboard, e.g. Now opening a multi-panel component opens it in a nested dashboard, and the behaviour is consistent.
|
| // We may need to check if we need to close this widget if all panels are closed | ||
| const [isPanelsDirty, setPanelsDirty] = useState(false); | ||
|
|
||
| const id = useMemo( |
There was a problem hiding this comment.
It looks to me like this id is only used for debug logging? It might be more useful to add as much info to the id as is defined (e.g. id-name-type if it has all three).
| uri?: UriVariableDescriptor; | ||
| }; | ||
|
|
||
| export function UIComponent(props: UIComponentProps): JSX.Element | null { |
There was a problem hiding this comment.
We should add a comment explaining UIComponent.
|
|
||
| type UIWidgetProps = WidgetComponentProps<dh.Widget>; | ||
|
|
||
| export function UIWidget(props: UIWidgetProps): JSX.Element | null { |
There was a problem hiding this comment.
We should also have a comment explaining UIWidget.
| import PortalPanel from './layout/PortalPanel'; | ||
| import UIWidget from './UIWidget'; | ||
|
|
||
| export const UIWidgetPlugin: WidgetPlugin<dh.Widget> = { |
There was a problem hiding this comment.
We should also have a comment explaining UIWidgetPlugin.
| // eslint-disable-next-line react/jsx-no-useless-fragment | ||
| <></> | ||
| ), | ||
| // We only want to update this callback when the descriptor changes, not |
There was a problem hiding this comment.
Why do we update this callback as the return value never changes? I can see that we do it intentionally. Is it to trigger an update in WidgetHandler when the descriptor changes?
There was a problem hiding this comment.
Good catch, I re-wired this and it shouldn't need to change on the descriptor anymore.
- Use the content of the panel instead of the full dashboard
|
ui docs preview (Available for 14 days) |
|
@dsmmcken ui.spec.ts-snapshots: I have it opening the ui_render_all from the embed widget screen, rather than the main app; because dashboards now open as nested dashboards (within a panel in the Code Studio). Because of that, it's a slightly different height (because there's no dashboards listed across the top from the embed widget view). |
|
ui docs preview (Available for 14 days) |
dgodinez-dh
left a comment
There was a problem hiding this comment.
Changes look good. Looks like there is a failing test though.
- These weren't actually an issue the issue I was trying to fix, but the type errors I was getting in CI don't make sense: https://github.com/deephaven/deephaven-plugins/actions/runs/25740228037/job/75588279678?pr=1341 - References REACT_PANEL_VISIBLE not being a valid symbol in ui_table.spec.ts, but that's not used anywhere in that file - Pushing this fix to see if it kicks CI into behaving
|
ui docs preview (Available for 14 days) |
…ards - So we can still open widgets as dashboards from code studios
|
ui docs preview (Available for 14 days) |
show_headersoption that can be set to False to not show headers on a dashboard. Useful if you're doing a homescreen type dashboard